#pragma once
//============================================================================
// Copyright (C) 2013 Brett R. Jones
//
// Issued to public domain 2013
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================
#ifdef WIN_PLATFORM
    #include <WinSock2.h>
    #include <windows.h>
#else
    #include <semaphore.h>
#endif

class VxSemaphore
{
public:
	//=== constructor ===//
	VxSemaphore();
	//=== constructor ===//
	~VxSemaphore();

	//=== methods ===//
	//! wait until another thread calls Signal
	//! if iTimeoutMilliseconds == 0 then wait infinite time
	//! return true if was signaled else return false if timed out
	bool Wait( int iTimeoutMilliseconds = 0 );
	//! signal waiting thread to run
	int Signal( void );

	//=== vars ===//
#ifdef WIN_PLATFORM 
	HANDLE	        m_hAccessLock; // windows handle to semaphore
#else
	sem_t           m_oSemaphore; // linux semaphore
#endif
};
